source and dest are the canvases
to copy the image between.
filter[] is an array of numbers that defines
the filter that is applied as the image is copied.
The filter is applied
to each of the pixels in turn until the entire image is copied.
Each pixel in the dest
canvas is calculated using the filter and the pixels from the
source canvas.
Suppose we have a filter
which is specified like this...
0,0,0
0,1,0
0,0,0
Suppose the filter is
currently being applied to pixel x,y. The pixel x,y in the dest
canvas is calculated like this...
pixel x-1, y-1 * 0 +
pixel x, y-1 * 0 +
pixel x+1, y-1 * 0 +
pixel x-1, y * 0 +
pixel x, y * 1 +
pixel x+1, y * 0 +
pixel x-1, y+1 * 0 +
pixel x, y+1 * 0 +
pixel x+1, y+1 * 0
This works out as a direct
copy from one canvas to the other.
The filter is only applied
to the pixels in the canvas that it can be. eg. if the filter
is 5 pixels wide then it will not be applied to the pixels which
are 2 pixels or less away from the edges. This is because the
dest pixel cannot be calculated since the filter would go off
the sides of the source canvas.
Note: This function only works in software mode.